/*
 *  Copyright 2009 Coditate Software
 *  Licensed under the GNU Library General Public License (LGPL) 2.1 
 *  
 *  License available at: http://simplesavant.codeplex.com/license
 */
using Amazon.SimpleDB;
using Coditate.Common.Util;

namespace Coditate.Savant.Core
{
    /// <summary>
    /// Base class for Savant implementations that decorate other implementations.
    /// </summary>
    internal abstract class DecoratingSavant : ISimpleSavant2Ex
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DecoratingSavant"/> class.
        /// </summary>
        /// <param name="decoratedSavant">The decorated savant.</param>
        protected DecoratingSavant(ISimpleSavant2Ex decoratedSavant)
        {
            Arg.CheckNull("decoratedSavant", decoratedSavant);

            DecoratedSavant = decoratedSavant;
        }

        /// <summary>
        /// Gets or sets the decorated savant implementation.
        /// </summary>
        /// <value>The decorated savant.</value>
        public ISimpleSavant2Ex DecoratedSavant { get; protected set; }

        public virtual void PutAttributes(ItemMapping mapping, params PropertyValues[] values)
        {
            DecoratedSavant.PutAttributes(mapping, values);
        }

        public virtual PropertyValues GetAttributes(ItemMapping mapping, object itemName, params string[] propertyNames)
        {
            return DecoratedSavant.GetAttributes(mapping, itemName, propertyNames);
        }

        public virtual void DeleteAttributes(ItemMapping mapping, object itemName, params string[] propertyNames)
        {
            DecoratedSavant.DeleteAttributes(mapping, itemName, propertyNames);
        }

        public virtual SelectResults<PropertyValues> SelectAttributes(SelectCommand command)
        {
            return DecoratedSavant.SelectAttributes(command);
        }

        public virtual object SelectScalar(SelectCommand command)
        {
            return DecoratedSavant.SelectScalar(command);
        }

        /// <summary>
        /// Gets or sets the simple db client.
        /// </summary>
        /// <value>The simple db.</value>
        public AmazonSimpleDB SimpleDB
        {
            get { return DecoratedSavant.SimpleDB; }
        }

        /// <summary>
        /// Gets or sets the configuration settings.
        /// </summary>
        /// <value>The config settings.</value>
        public SavantConfig Config
        {
            get { return DecoratedSavant.Config; }
        }
    }
}